//Keyword:Create template file
//Url:http://cocoawithlove.com/2009/07/temporary-files-and-folders-in-cocoa.html
//Sample Code:


NSString *tempDirectoryTemplate =
    [NSTemporaryDirectory() stringByAppendingPathComponent:@"myapptempdirectory.XXXXXX"];
const char *tempDirectoryTemplateCString =
    [tempDirectoryTemplate fileSystemRepresentation];
char *tempDirectoryNameCString =
    (char *)malloc(strlen(tempDirectoryTemplateCString) + 1);
strcpy(tempDirectoryNameCString, tempDirectoryTemplateCString);

char *result = mkdtemp(tempDirectoryNameCString);
if (!result)
{
    // handle directory creation failure
}

NSString *tempDirectoryPath =
    [[NSFileManager defaultManager]
        stringWithFileSystemRepresentation:tempDirectoryNameCString
        length:strlen(result)];
free(tempDirectoryNameCString);